<?php
error_reporting(0);
require_once 'model/api/Taoapi.php';
require_once 'config.php';

$num_iid= $_GET['num_iid'];
$tplFile="view.html";
$tplCache=$num_iid;
$smar=new MySmarty($cache,$cachetime,$moban);
$smarty=$smar->get_smarty();
if(!$smarty->is_cached($tplFile,$tplCache)){
	$Taoapi_Config = Taoapi_Config::Init();
	$Taoapi_Config->setCharset('UTF-8');	$Taoapi_Config->setAppKey($app);
	$Taoapi = new Taoapi;
	$Taoapi->method = 'taobao.taobaoke.items.detail.get';
	$Taoapi->fields = 'iid,title,nick,post_fee,express_fee,ems_fee,cid,desc,num,price,list_time,delist_time,pic_url,location,seller_credit_score,click_url,shop_click_url,props,props_name';
	$Taoapi->num_iids = $num_iid;
	$Taoapi->nick = $usernick;
	$result = $Taoapi->Send('get','xml')->getArrayData();
	
	$taobaokeItem = $result['taobaoke_item_details']["taobaoke_item_detail"];
	$iid=$taobaokeItem['item']['iid'];
	$titles = $taobaokeItem['item']['title'];
	$nick = $taobaokeItem['item']['nick'];
	$post_fee = $taobaokeItem['item']['post_fee'];
	$express_fee = $taobaokeItem['item']['express_fee'];
	$ems_fee = $taobaokeItem['item']['ems_fee'];
	$catid = $taobaokeItem['item']['cid'];
	$desc = $taobaokeItem['item']['desc'];
	$num = $taobaokeItem['item']['num'];
	$price = $taobaokeItem['item']['price'];
	$list_time = $taobaokeItem['item']['list_time'];
	$delist_time = $taobaokeItem['item']['delist_time'];
	$pic_path = $taobaokeItem['item']['pic_url'];
	$city = $taobaokeItem['item']['location']['city'];
	$state = $taobaokeItem['item']['location']['state'];
	$feature=$taobaokeItem['item']['props'];
	$level = $taobaokeItem['seller_credit_score'];
	$click_url = $taobaokeItem['click_url'];
	$shop_click_url=$taobaokeItem['shop_click_url'];


	$Taoapi2 = new Taoapi;
	$Taoapi2->method = 'taobao.itemcats.get';
	$Taoapi2->fields = 'cid,name,is_parent,parent_cid';
	$Taoapi2->cids = $catid;
	$result2 = $Taoapi2->Send('get','xml')->getArrayData();
	$result2 = $result2['item_cats']['item_cat'];
	
	if($result2['parent_cid']>0){
		$Taoapi1 = new Taoapi;
		$Taoapi1->method = 'taobao.itemcats.get';
		$Taoapi1->fields = 'cid,name';
		$Taoapi1->cids = $result2['parent_cid'];
		$result1 = $Taoapi1->Send('get','xml')->getArrayData();
		$result1 = $result1['item_cats']['item_cat'];
	}

	$Taoapi3 = new Taoapi;
	$Taoapi3->method = 'taobao.itempropvalues.get';
	$Taoapi3->fields = 'prop_name,name';
	$Taoapi3->cid = $result2["cid"];
	$Taoapi3->pvs = $feature;
	$result3 = $Taoapi3->Send('get','xml')->getArrayData();
	$featurevalue=$result3['prop_values']['prop_value'];


	$tags=explode(" ",$titles);
	$thistitle=$titles;
	
	include("head.php");
	
	if($result1){
		$pcat.= "<a href=".$website."/remai".$ljoin.$lcat.$result1["cid"].$ljoin.$lpage."1".$rewrite_postfix.">".$result1["name"]."</a> > ";
	}
	$pcat.= "<a href=".$website."/remai".$ljoin.$lcat.$result2["cid"].$ljoin.$lpage."1".$rewrite_postfix.">".$result2["name"]."</a>";
	
	$i=1;
	$a=$featurevalue[0];
	foreach($featurevalue as $row){
		if($i>1){
			if($row['prop_name']==$a['prop_name']){
				$row['name'].=" ".$a['name'];
				$title=$row['prop_name'];
				$content=$row['name'];
				$a=$row;
			}else{
				$a=$row;
				if(!$title){
					$title=$row['prop_name'];
					$content=$row['name'];
				}
				$con=$content;
				$content=mysubstr($content,40,'..');
				$features[] = "<li title='".$con."'>".str_replace($result2['name'],"",$title).":".$content."</li>";
				$title='';
				$content='';
			};
			$i++;
		}else{
			$i++;
		}
	} 
	
	preg_match("/^var desc=\'(.*)\';$/isU",$content1,$con);
	$pat = "/<(\/?)(script|i?frame|style|html|body|title|link|a|meta|\?|\%)([^>]*?)>/isU";
	$tbinfo = $con[1];
	$abc=preg_replace($pat,"",$desc);
	$prefixurl="view";
	
	include("foot.php");
	//head
	$smarty->assign("thistitle",$thistitle);
	$smarty->assign("q",$q);
	$smarty->assign("result2",$result2);
	$smarty->assign("webname",$webname);
	$smarty->assign("postfix",$postfix);
	$smarty->assign("description",$description);
	$smarty->assign("keywords",$keywords);
	$smarty->assign("website",$website);
	$smarty->assign("moban",$moban);
	$smarty->assign("searchkeys",$searchkeys);
	$smarty->assign("newshops",$newshops);
	//category
	$smarty->assign("prefixurl",$prefixurl);
	$smarty->assign("lcat",$lcat);
	$smarty->assign("lpro",$lpro);
	$smarty->assign("lpage",$lpage);
	$smarty->assign("rewrite_postfix",$rewrite_postfix);
	$smarty->assign("ljoin",$ljoin);
	//foot
	$smarty->assign("ads",$ads);
	$smarty->assign("links",$links);
	$smarty->assign("QQ",$QQ);
	$smarty->assign("ICP",$ICP);
	$smarty->assign("tongji",$tongji);
$smarty->assign("jiathis",$jiathis);
	//view
	$smarty->assign("abc",$abc);
	$smarty->assign("pcat",$pcat);
	$smarty->assign("features",$features);
	$smarty->assign("result1",$result1);
	$smarty->assign("v",$v);
	$smarty->assign("catid",$catid);
	$smarty->assign("num_iid",$num_iid);
	$smarty->assign("titles",$titles);
	$smarty->assign("num",$num);
	$smarty->assign("nick",$nick);
	$smarty->assign("city",$city);
	$smarty->assign("state",$state);
	$smarty->assign("level",$level);
	$smarty->assign("click_url",$click_url);
	$smarty->assign("shop_click_url",$shop_click_url);
	$smarty->assign("price",$price);
	$smarty->assign("tags",$tags);
	$smarty->assign("pic_path",$pic_path);
}
$smarty->display($tplFile,$tplCache);
?>